package com.weixing.mall.provider.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.weixing.mall.base.orm.MPage;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.annotation.NoNeedAccess;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.core.support.auth.AuthUtil;
import com.weixing.mall.core.utils.CommonUtil;
import com.weixing.mall.provider.api.model.enums.OrderTypeEnum;
import com.weixing.mall.provider.model.vo.report.customer.CustomerReportDetailVo;
import com.weixing.mall.provider.model.vo.report.customer.CustomerSeckillBonusDetailVo;
import com.weixing.mall.provider.model.vo.report.customer.CustomerSeckillBonusOneVo;
import com.weixing.mall.provider.model.vo.report.customer.CustomerSeckillBonusTwoVo;
import com.weixing.mall.provider.model.vo.report.market.*;
import com.weixing.mall.provider.service.IDayReportMarketService;
import com.weixing.mall.provider.util.EasyExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jzy
 * @date 2020/5/18
 */
@RestController
@RequestMapping("report")
@Api(value = "后台报表APi", tags = "后台报表-市场部报表")
public class ReportMarketController extends BaseController {
    @Autowired
    private IDayReportMarketService dayReportMarketService;

    @ApiOperation(value = "1市场部报表--销售情况报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动", required = false, paramType = "query"),
    })
    @GetMapping("/market/sales/status")
    public Result<IPage<MarketSalesStatusVo>> marketSalesStatus(Integer roleType, Long agentId, String startTime, String endTime, Integer year, Integer orderType, String sortField, String sortType) {
        IPage<MarketSalesStatusVo> page = dayReportMarketService.marketSalesStatus(roleType, agentId, startTime, endTime, orderType, year, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "1市场部报表--销售情况报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"), @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动", required = false, paramType = "query"),

    })
    @GetMapping("/market/sales/status/excel")
    @NoNeedAccess
    public void marketSalesStatusExcel(Integer roleType, Long agentId, String startTime, String endTime, Integer orderType, Integer year, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketSalesStatusVo> page = dayReportMarketService.marketSalesStatus(roleType, agentId, startTime, endTime, orderType, year, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketSalesStatusVo.class, page.getRecords(), "销售情况报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "1市场部报表--销售情况报表-详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = " 0所有   1只查自己", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名", required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderStatus", value = "订单状态  1全部总量 2实际总量 3退货总量 4断货总量 5取消总量 6瑕疵总量  7问题总量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "date", value = "日期", required = false, paramType = "query"),
    })
    @GetMapping("/market/sales/status/detail")
    public Result<MPage<CustomerReportDetailVo>> customerFinanceDetail(Integer isOwn, Integer roleType, Long agentId, Long agentPid, String startTime, String endTime, String role, String userName, String mobile, Integer orderType, Integer orderStatus, Long actId, String sortField, String sortType, String date) {
        IPage<CustomerReportDetailVo> page = dayReportMarketService.marketSalesStatusDetail(isOwn, roleType, agentId, agentPid, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, sortField, sortType, date, initMpPage());
        Map<String, Object> map = dayReportMarketService.marketSalesStatusTotal(isOwn, roleType, agentId, agentPid, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, date);
        MPage<CustomerReportDetailVo> mPage = new MPage<>();
        BeanUtils.copyProperties(page, mPage);
        if (MapUtil.isEmpty(map)) {
            map = new HashMap<>();
        }
        mPage.setMap(map);
        return ResultUtil.success(mPage);
    }

    @ApiOperation(value = "1市场部报表--销售情况报表-详情-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = " 0所有   1只查自己", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名", required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderStatus", value = "订单状态  1全部总量 2实际总量 3退货总量 4断货总量 5取消总量 6瑕疵总量  7问题总量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "date", value = "日期", required = false, paramType = "query"),
    })
    @GetMapping("/market/sales/status/detail/excel")
    @NoNeedAccess
    public void customerFinanceDetailExcel(Integer isOwn, Integer roleType, Long agentId, Long agentPid, String startTime, String endTime, String role, String userName, String mobile, Integer orderType, Integer orderStatus, Long actId, String sortField, String sortType, String date, HttpServletResponse response) {
        IPage<CustomerReportDetailVo> page = dayReportMarketService.marketSalesStatusDetail(isOwn, roleType, agentId, agentPid, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, sortField, sortType, date, new Page(1, -1));
        List<CustomerReportDetailVo> records = page.getRecords();
        try {
            EasyExcelUtil.writeExcel(response, CustomerReportDetailVo.class, records, "订单明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @ApiOperation(value = "2市场部报表--代理数据分析报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
    })
    @GetMapping("/market/agent/data")
    public Result<IPage<MarketAgentDataAnalysisVo>> marketAgentData(Integer roleType, Long agentId, String startTime, String endTime, Integer year, String sortField, String sortType) {
        IPage<MarketAgentDataAnalysisVo> page = dayReportMarketService.marketAgentData(roleType, agentId, startTime, endTime, year, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "2市场部报表--代理数据分析报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
    })
    @GetMapping("/market/agent/data/excel")
    @NoNeedAccess
    public void marketAgentDataExcel(Integer roleType, Long agentId, String startTime, String endTime, Integer year, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketAgentDataAnalysisVo> page = dayReportMarketService.marketAgentData(roleType, agentId, startTime, endTime, year, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketAgentDataAnalysisVo.class, page.getRecords(), "代理数据分析报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "3市场部报表--区域销售报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "queryType", value = "查询方式 1按照省排序，2按照市排序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "province", value = "省份 省份为空表示是全国", required = false, paramType = "query"),
            @ApiImplicitParam(name = "city", value = "城市", required = false, paramType = "query"),
            @ApiImplicitParam(name = "region", value = "区", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query")
    })
    @GetMapping("/market/report/area")
    public Result<List<MarketAreaSalesVo>> areaReport(Integer queryType, String province, String city, String region, String startTime, String endTime) {
        // List<MarketAreaSalesVo> list = dayReportMarketService.areaReport(province, city, region, startTime, endTime);
        List<MarketAreaSalesVo> list = dayReportMarketService.areaReport2(queryType, province, city, startTime, endTime);
        return ResultUtil.success(list);
    }


    @ApiOperation(value = "3市场部报表--区域销售报表导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "queryType", value = "查询方式 1按照省排序，2按照市排序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "province", value = "省份 省份为空表示是全国", required = false, paramType = "query"),
            @ApiImplicitParam(name = "city", value = "城市", required = false, paramType = "query"),
            @ApiImplicitParam(name = "region", value = "区", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query")
    })
    @GetMapping("/market/report/area/excel")
    public void areaReportExcel(Integer queryType, String province, String city, String region, String startTime, String endTime, HttpServletResponse response) {
        // List<MarketAreaSalesVo> list = dayReportMarketService.areaReport(province, city, region, startTime, endTime);
        List<MarketAreaSalesVo> list = dayReportMarketService.areaReport2(queryType, province, city, startTime, endTime);
        try {
            EasyExcelUtil.writeExcel(response, MarketAreaSalesVo.class, list, "区域销售报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "level", value = "等级", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "客服/代理名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus")
    public Result<IPage<MarketRegularActBonusVo>> marketRegularAgent(Integer level, Integer roleType, Long agentId, String userName, Integer orderType, String actName, String startTime, String endTime, String sortField, String sortType) {
        IPage<MarketRegularActBonusVo> page = dayReportMarketService.regularActBonus(level, roleType, agentId, userName, orderType, actName, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "level", value = "等级", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "客服/代理名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus/excel")
    @NoNeedAccess
    public void marketRegularAgentExcel(Integer level, Integer roleType, Long agentId, String userName, Integer orderType, String actName, String startTime, String endTime, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketRegularActBonusVo> page = dayReportMarketService.regularActBonus(level, roleType, agentId, userName, orderType, actName, startTime, endTime, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketRegularActBonusVo.class, page.getRecords(), "正价跟代理商活动返还款汇总");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总--查看2%分红（一级分红）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus/one")
    public Result<IPage<CustomerSeckillBonusOneVo>> bonusOne(Integer roleType, Long agentId, String userName, Integer orderType, String actName, String startTime, String endTime, String sortField, String sortType) {
        IPage<CustomerSeckillBonusOneVo> page = dayReportMarketService.regularActBonusOne(roleType, agentId, userName, orderType, actName, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总--查看2%分红（一级分红）-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus/one/excel")
    @NoNeedAccess
    public void bonusOneExcel(Integer roleType, Long agentId, String userName, Integer orderType, String actName, String startTime, String endTime, String sortField, String sortType, HttpServletResponse response) {
        IPage<CustomerSeckillBonusOneVo> page = dayReportMarketService.regularActBonusOne(roleType, agentId, userName, orderType, actName, startTime, endTime, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillBonusOneVo.class, page.getRecords(), "一级分红明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总--查看1%分红（二级分红）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName1", value = "经销商关系名称(一级分红人)", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus/two")
    public Result<IPage<CustomerSeckillBonusTwoVo>> bonusTwo(Integer roleType, Long agentId, String userName1, String userName, Integer orderType, String actName, String startTime, String endTime, String sortField, String sortType) {
        IPage<CustomerSeckillBonusTwoVo> page = dayReportMarketService.regularActBonusTwo(roleType, agentId, userName1, userName, orderType, actName, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总--查看1%分红（二级分红）-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName1", value = "经销商关系名称(一级分红人)", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus/two/excel")
    @NoNeedAccess
    public void bonusTwoExcel(Integer roleType, Long agentId, String userName1, String userName, Integer orderType, String actName, String startTime, String endTime, String sortField, String sortType, HttpServletResponse response) {
        IPage<CustomerSeckillBonusTwoVo> page = dayReportMarketService.regularActBonusTwo(roleType, agentId, userName1, userName, orderType, actName, startTime, endTime, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillBonusTwoVo.class, page.getRecords(), "二级分红明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总--分红订单明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型  1一级分红（2%）  2二级分红（1%）", required = true, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus/detail")
    public Result<IPage<CustomerSeckillBonusDetailVo>> bonusDetail(Integer type, Integer orderType, String actName, Integer roleType, Long agentId, String startTime, String endTime, String sortField, String sortType) {
        IPage<CustomerSeckillBonusDetailVo> page = dayReportMarketService.regularActBonusDetail(type, orderType, actName, roleType, agentId, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价跟4折活动返还款汇总--分红订单明细-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型  1一级分红（2%）  2二级分红（1%）", required = true, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/bonus/detail/excel")
    @NoNeedAccess
    public void bonusDetailExcel(Integer type, Integer orderType, String actName, Integer roleType, Long agentId, String startTime, String endTime, String sortField, String sortType, HttpServletResponse response) {
        IPage<CustomerSeckillBonusDetailVo> page = dayReportMarketService.regularActBonusDetail(type, orderType, actName, roleType, agentId, startTime, endTime, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillBonusDetailVo.class, page.getRecords(), "分红订单明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价订单汇总")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "父角色", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/regular")
    public Result<IPage<MarketRegularAgentVo>> regularOrder(Integer roleType, Long agentId, Long agentPid, Integer pRole, String startTime, String endTime, String sortField, String sortType) {
        IPage<MarketRegularAgentVo> page = dayReportMarketService.regularAndActivity(roleType, agentId, agentPid, pRole, OrderTypeEnum.NORMAL.getValue(), startTime, endTime, null, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-正价订单汇总-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "父角色", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/regular/excel")
    @NoNeedAccess
    public void regularOrderExcel(Integer roleType, Long agentId, Long agentPid, Integer pRole, String startTime, String endTime, String actName, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketRegularAgentVo> page = dayReportMarketService.regularAndActivity(roleType, agentId, agentPid, pRole, OrderTypeEnum.NORMAL.getValue(), startTime, endTime, actName, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketRegularAgentVo.class, page.getRecords(), "正价订单汇总");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-4折活动订单汇总表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "父角色", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/agent")
    public Result<IPage<MarketRegularAgentVo>> agentOrder(Integer roleType, Long agentId, Long agentPid, Integer pRole, String startTime, String endTime, String actName, String sortField, String sortType) {
        IPage<MarketRegularAgentVo> page = dayReportMarketService.regularAndActivity(roleType, agentId, agentPid, pRole, OrderTypeEnum.AGENT.getValue(), startTime, endTime, actName, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-4折活动订单汇总表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "父角色", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/agent/excel")
    @NoNeedAccess
    public void agentOrderExcel(Integer roleType, Long agentId, Long agentPid, Integer pRole, String startTime, String endTime, String actName, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketRegularAgentVo> page = dayReportMarketService.regularAndActivity(roleType, agentId, agentPid, pRole, OrderTypeEnum.AGENT.getValue(), startTime, endTime, actName, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketRegularAgentVo.class, page.getRecords(), "4折活动订单汇总表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-2.5折活动订单汇总表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "父角色", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/seckill")
    public Result<IPage<MarketRegularAgentVo>> seckillOrder(Integer roleType, Long agentId, Long agentPid, Integer pRole, String startTime, String endTime, String actName, String sortField, String sortType) {
        IPage<MarketRegularAgentVo> page = dayReportMarketService.regularAndActivity(roleType, agentId, agentPid, pRole, OrderTypeEnum.SECKILL.getValue(), startTime, endTime, actName, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "4市场部报表--正价跟代理活动汇总表-2.5折活动订单汇总表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "父Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "父角色", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/regular/agent/seckill/excel")
    @NoNeedAccess
    public void seckillOrderExcel(Integer roleType, Long agentId, Long agentPid, Integer pRole, String startTime, String endTime, String actName, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketRegularAgentVo> page = dayReportMarketService.regularAndActivity(roleType, agentId, agentPid, pRole, OrderTypeEnum.SECKILL.getValue(), startTime, endTime, actName, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketRegularAgentVo.class, page.getRecords(), "2.5折活动订单汇总表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "5市场部报表--推荐人报表-收益方")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "distributorId", value = "经销商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteStatus", value = "晋升状态  1晋升前 2晋升后 空是全部", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteTime", value = "晋升时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型  1正价订单 2代理商活动订单  3秒杀活动订单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/referrer")
    public Result<IPage<MarketReferrerVo>> referrerReport(Integer roleType, Long agentId, Long distributorId, Integer promoteStatus, String promoteTime, Integer orderType, Long actId, String startTime, String endTime, String sortField, String sortType) {
        IPage<MarketReferrerVo> page = dayReportMarketService.referrerReport(roleType, agentId, distributorId, promoteStatus, promoteTime, orderType, actId, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "5市场部报表--推荐人报表-导出excel-收益方")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "distributorId", value = "经销商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteStatus", value = "晋升状态  1晋升前 2晋升后 空是全部", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteTime", value = "晋升时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型  1正价订单 2代理商活动订单  3秒杀活动订单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动ID", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/referrer/excel")
    @NoNeedAccess
    public void referrerReportExcel(Integer roleType, Long agentId, Long distributorId, Integer promoteStatus, String promoteTime, Integer orderType, Long actId, String startTime, String endTime, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketReferrerVo> page = dayReportMarketService.referrerReport(roleType, agentId, distributorId, promoteStatus, promoteTime, orderType, actId, startTime, endTime, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketReferrerVo.class, page.getRecords(), "推荐人报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "5市场部报表--推荐人报表--获取经销商下的所有合伙人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "type", value = "分红关系 空是所有 1 一级分红关系  2 二级分红关系", required = true, paramType = "query")
    })
    @GetMapping("/market/report/referrer/partners")
    public Result<List<ReferrerAgentVo>> referrerReportAgents(Integer roleType, Long agentId, Integer type) {
        List<ReferrerAgentVo> agentVos = dayReportMarketService.referrerReportAgents(roleType, agentId, type);
        return ResultUtil.success(agentVos);
    }

    @ApiOperation(value = "5市场部报表--推荐人报表--获取经销商下的所有合伙人-发放")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "bonusId", value = "分红人Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "type", value = "分红关系 空是所有 1 一级发放人 2 二级发放人", required = true, paramType = "query")
    })
    @GetMapping("/market/report/referrer/partners/send")
    public Result<List<ReferrerAgentVo>> referrerReportAgentsSend(Integer roleType, Long agentId, Integer type, Long bonusId) {
        List<ReferrerAgentVo> agentVos = dayReportMarketService.referrerReportAgentsSend(roleType, agentId, type, bonusId);
        return ResultUtil.success(agentVos);
    }

    @ApiOperation(value = "5市场部报表--推荐人报表--所有分红人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "partnerId", value = "业绩人id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "type", value = "分红关系 空是所有 1 一级发放人 2 二级发放人", required = true, paramType = "query")
    })
    @GetMapping("/market/report/referrer/bonus/send")
    public Result<List<ReferrerAgentVo>> referrerReportBonusSend(Integer roleType, Long agentId, Integer type, Long partnerId) {
        List<ReferrerAgentVo> agentVos = dayReportMarketService.referrerReportBonusAgent(roleType, agentId, type, partnerId);
        return ResultUtil.success(agentVos);
    }

    @ApiOperation(value = "5市场部报表--推荐人报表-发放")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "distributorId", value = "经销商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "bonusId", value = "分红人Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteStatus", value = "晋升状态  1晋升前 2晋升后 空是全部", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteTime", value = "晋升时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型  1正价订单 2代理商活动订单  3秒杀活动订单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动ID", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/referrer/send")
    public Result<IPage<MarketReferrerSendVo>> referrerSendReport(Integer roleType, Long agentId, Long distributorId, Long bonusId, Integer promoteStatus, String promoteTime, Integer orderType, Long actId, String startTime, String endTime, String sortField, String sortType) {
        IPage<MarketReferrerSendVo> page = dayReportMarketService.referrerReportSend(roleType, agentId, distributorId, bonusId, promoteStatus, promoteTime, orderType, actId, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "5市场部报表--推荐人报表-导出excel-发放")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "distributorId", value = "经销商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "bonusId", value = "分红人Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteStatus", value = "晋升状态  1晋升前 2晋升后 空是全部", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteTime", value = "晋升时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型  1正价订单 2代理商活动订单  3秒杀活动订单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动ID", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query")
    })
    @GetMapping("/market/report/referrer/send/excel")
    @NoNeedAccess
    public void referrerSendReportExcel(Integer roleType, Long agentId, Long distributorId, Long bonusId, Integer promoteStatus, String promoteTime, Integer orderType, Long actId, String startTime, String endTime, String sortField, String sortType, HttpServletResponse response) {
        IPage<MarketReferrerSendVo> page = dayReportMarketService.referrerReportSend(roleType, agentId, distributorId, bonusId, promoteStatus, promoteTime, orderType, actId, startTime, endTime, sortField, sortType, new Page(1, -1));
        try {
            EasyExcelUtil.writeExcel(response, MarketReferrerSendVo.class, page.getRecords(), "推荐人报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "5市场部报表--推荐人报表-详情-受益人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = " 0所有   1只查自己", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentType", value = "类型 1受益人 2发放人", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名", required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderStatus", value = "订单状态  1全部总量 2实际总量 3退货总量 4断货总量 5取消总量 6瑕疵总量  7问题总量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "distributorId", value = "经销商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "issuerId", value = "发放人Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "issuerRole", value = "发放人角色  1客服 2代理商", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteStatus", value = "晋升状态  1晋升前 2晋升后 空是全部", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteTime", value = "晋升时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "fromAgent", value = "是否来自代理后台  0否   1是", required = false, paramType = "query"),
    })
    @GetMapping("/market/report/referrer/detail")
    public Result<MPage<CustomerReportDetailVo>> referrerDetail(Integer isOwn,
                                                                Integer roleType,
                                                                Long agentId,
                                                                Integer agentType,
                                                                String startTime,
                                                                String endTime,
                                                                String role,
                                                                String userName,
                                                                String mobile,
                                                                Integer orderType,
                                                                Integer orderStatus,
                                                                Long actId,
                                                                String sortField,
                                                                String sortType,
                                                                Long distributorId,
                                                                Long issuerId,
                                                                Integer issuerRole,
                                                                Integer promoteStatus,
                                                                String promoteTime,
                                                                Integer fromAgent) {
        IPage<CustomerReportDetailVo> page = dayReportMarketService.referrerReportDetail(isOwn, roleType, agentId, agentType, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, sortField, sortType, distributorId, issuerId, issuerRole, promoteStatus, promoteTime, initMpPage());
        if (null != fromAgent && 1 == fromAgent.intValue()) {
            Long aid = AuthUtil.getAgentExt().getAid();
            List<CustomerReportDetailVo> records = page.getRecords();
            if (CollUtil.isNotEmpty(records)) {
                for (CustomerReportDetailVo vo : records) {
                    if (aid.longValue() != vo.getAgentId().longValue()) {
                        vo.setContactPhone(CommonUtil.coverMobile(vo.getContactPhone()));
                    }
                }
            }
        }

        Map<String, Object> map = dayReportMarketService.referrerReportDetailTotal(isOwn, roleType, agentId, agentType, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, distributorId, issuerId, issuerRole, promoteStatus, promoteTime);
        MPage<CustomerReportDetailVo> mPage = new MPage<>();
        BeanUtils.copyProperties(page, mPage);
        if (MapUtil.isEmpty(map)) {
            map = new HashMap<>();
        }
        mPage.setMap(map);
        return ResultUtil.success(mPage);
    }

    @ApiOperation(value = "5市场部报表--推荐人报表-详情-发放人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = " 0所有   1只查自己", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentType", value = "类型 1受益人 2发放人", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名", required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderStatus", value = "订单状态  1全部总量 2实际总量 3退货总量 4断货总量 5取消总量 6瑕疵总量  7问题总量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "distributorId", value = "经销商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteStatus", value = "晋升状态  1晋升前 2晋升后 空是全部", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteTime", value = "晋升时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "bonusId", value = "分红代理商Id", required = false, paramType = "query"),
    })
    @GetMapping("/market/report/referrer/send/detail")
    public Result<MPage<CustomerReportDetailVo>> referrerSendDetail(Integer isOwn, Integer roleType, Long agentId, Integer agentType, String startTime, String endTime, String role, String userName, String mobile, Integer orderType, Integer orderStatus, Long actId, String sortField, String sortType, Long distributorId, Integer promoteStatus, String promoteTime , Long bonusId) {
        IPage<CustomerReportDetailVo> page = dayReportMarketService.referrerReportSendDetail(isOwn, roleType, agentId, agentType, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, sortField, sortType, distributorId, promoteStatus, promoteTime, bonusId, initMpPage());
        Map<String, Object> map = dayReportMarketService.referrerReportSendDetailTotal(isOwn, roleType, agentId, agentType, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, distributorId, promoteStatus, promoteTime, bonusId);
        MPage<CustomerReportDetailVo> mPage = new MPage<>();
        BeanUtils.copyProperties(page, mPage);
        if (MapUtil.isEmpty(map)) {
            map = new HashMap<>();
        }
        mPage.setMap(map);
        return ResultUtil.success(mPage);
    }

    @ApiOperation(value = "5市场部报表--推荐人报表-详情-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = " 0所有   1只查自己", required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentType", value = "类型 1 受益人 2发放人", required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单", required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名", required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动", required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderStatus", value = "订单状态  1全部总量 2实际总量 3退货总量 4断货总量 5取消总量 6瑕疵总量  7问题总量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "distributorId", value = "合伙人Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "issuerId", value = "发放人Id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "issuerRole", value = "发放人角色  1客服 2代理商", required = false, paramType = "query"),
            @ApiImplicitParam(name = "promoteStatus", value = "晋升状态  1晋升前 2晋升后 空是全部", required = false, paramType = "query"),
            @ApiImplicitParam(name = "fromAgent", value = "是否来自代理后台  0否   1是", required = false, paramType = "query"),
    })
    @GetMapping("/market/report/referrer/detail/excel")
//    @NoNeedAccess
    public void customerFinanceDetailExcel(Integer isOwn,
                                           Integer roleType,
                                           Long agentId,
                                           Integer agentType,
                                           String startTime,
                                           String endTime,
                                           String role,
                                           String userName,
                                           String mobile,
                                           Integer orderType,
                                           Integer orderStatus,
                                           Long actId,
                                           String sortField,
                                           String sortType,
                                           Long distributorId,
                                           Long issuerId,
                                           Integer issuerRole,
                                           Integer promoteStatus,
                                           Integer fromAgent,
                                           String promoteTime,
                                           HttpServletResponse response) {
        IPage<CustomerReportDetailVo> page = dayReportMarketService.referrerReportDetail(isOwn, roleType, agentId, agentType, startTime, endTime, role, userName, mobile, orderType, orderStatus, actId, sortField, sortType, distributorId, issuerId, issuerRole, promoteStatus, promoteTime , new Page(1, -1));
        List<CustomerReportDetailVo> records = page.getRecords();
        try {
            if (null != fromAgent && 1 == fromAgent.intValue()) {
                Long aid = AuthUtil.getAgentExt().getAid();
                if (CollUtil.isNotEmpty(records)) {
                    for (CustomerReportDetailVo vo : records) {
                        if (aid.longValue() != vo.getAgentId().longValue()) {
                            vo.setContactPhone(CommonUtil.coverMobile(vo.getContactPhone()));
                        }
                    }
                }
            }
            EasyExcelUtil.writeExcel(response, CustomerReportDetailVo.class, records, "订单明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
